package cz.schovjan.proj.entity;

import java.util.Collection;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "MEMBER", schema = "PPRO")
public class MemberEntity {
	
	private Integer id;
	private String name;
	private String surname;
	private String nick;
	private String job;
	private String phone;
	private String email;
	private Date dateOfBirth;
	private Collection<BandEntity> bands;

	public MemberEntity() {
	}
	
	public MemberEntity(Integer id, String name, String surname, String nick,
			String job, String phone, String email, Date dateOfBirth) {
		this.id = id;
		this.name = name;
		this.surname = surname;
		this.nick = nick;
		this.job = job;
		this.phone = phone;
		this.email = email;
		this.dateOfBirth = dateOfBirth;
	}

	@Id
	@GeneratedValue
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "NAME", length = 50)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "SURNAME", length = 50)
	public String getSurname() {
		return surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	@Column(name = "NICK", length = 50)
	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}
	
	@Column(name = "JOB", length = 200)
	public String getJob() {
		return job;
	}
	
	public void setJob(String job) {
		this.job = job;
	}

	@Column(name = "PHONE", length = 20)
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "EMAIL", length = 50)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "DATE_OF_BIRTH", length = 50)
	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	
	@ManyToMany(mappedBy="members")
	public Collection<BandEntity> getBands() {
		return bands;
	}
	
	public void setBands(Collection<BandEntity> bands) {
		this.bands = bands;
	}
	
	@Override
	public String toString() {
		return "Member [id=" + id + ", name=" + name + ", lastName=" + surname
				+ ", nick=" + nick + ", job=" + job + ", phone=" + phone
				+ ", email=" + email + ", dateOfBirth=" + dateOfBirth + "]";
	}
}
